package com.work.model;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the Projects database table.
 * 
 */
@Entity
@Table(name="Projects")
@NamedQuery(name="Project.findAll", query="SELECT p FROM Project p")
public class Project implements Serializable {
	private static final long serialVersionUID = 1L;
	private int idProjects;
	private Date codeFreeze;
	private Date createdDate;
	private String domain;
	private Date endDate;
	private String name;
	private Date startDate;
	private Date updatedDate;
	private List<Codereview> codeReviews;
	private User userPM;
	private User userCreatedBy;
	private User userUpdatedBy;
	private List<Sprint> sprints;

	public Project() {
	}


	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public int getIdProjects() {
		return this.idProjects;
	}

	public void setIdProjects(int idProjects) {
		this.idProjects = idProjects;
	}


	@Temporal(TemporalType.TIMESTAMP)
	public Date getCodeFreeze() {
		return this.codeFreeze;
	}

	public void setCodeFreeze(Date codeFreeze) {
		this.codeFreeze = codeFreeze;
	}


	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}


	public String getDomain() {
		return this.domain;
	}

	public void setDomain(String domain) {
		this.domain = domain;
	}


	@Temporal(TemporalType.TIMESTAMP)
	public Date getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}


	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}


	@Temporal(TemporalType.TIMESTAMP)
	public Date getStartDate() {
		return this.startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}


	@Temporal(TemporalType.TIMESTAMP)
	public Date getUpdatedDate() {
		return this.updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}


	//bi-directional many-to-one association to CodeReview
	@OneToMany(mappedBy="projectBean")
	public List<Codereview> getCodeReviews() {
		return this.codeReviews;
	}

	public void setCodeReviews(List<Codereview> codeReviews) {
		this.codeReviews = codeReviews;
	}

	public Codereview addCodeReview(Codereview codeReview) {
		getCodeReviews().add(codeReview);
		codeReview.setProjectBean(this);

		return codeReview;
	}

	public Codereview removeCodeReview(Codereview codeReview) {
		getCodeReviews().remove(codeReview);
		codeReview.setProjectBean(null);

		return codeReview;
	}


	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="PM")
	public User getUserPM() {
		return this.userPM;
	}

	public void setUserPM(User userPM) {
		this.userPM = userPM;
	}


	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="CreatedBy")
	public User getUserCreatedBy() {
		return this.userCreatedBy;
	}

	public void setUserCreatedBy(User userCreatedBy) {
		this.userCreatedBy = userCreatedBy;
	}


	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="UpdatedBy")
	public User getUserUpdatedBy() {
		return this.userUpdatedBy;
	}

	public void setUserUpdatedBy(User userUpdatedBy) {
		this.userUpdatedBy = userUpdatedBy;
	}


	//bi-directional many-to-one association to Sprint
	@OneToMany(mappedBy="project")
	public List<Sprint> getSprints() {
		return this.sprints;
	}

	public void setSprints(List<Sprint> sprints) {
		this.sprints = sprints;
	}

	public Sprint addSprint(Sprint sprint) {
		getSprints().add(sprint);
		sprint.setProject(this);

		return sprint;
	}

	public Sprint removeSprint(Sprint sprint) {
		getSprints().remove(sprint);
		sprint.setProject(null);

		return sprint;
	}

}